import request from '@/utils/request'

const base_api = '/admin/system/sysRole'

//角色列表接口
export const GetSysRoleListByPage = (current, limit, queryDto) => {
  return request({
    url: `${base_api}/findByPage/${current}/${limit}`,
    method: 'post',
    //以json格式进行传递
    data: queryDto,
  })
}

//角色添加
export const SaveSysRole = sysRole => {
  return request({
    url: `${base_api}/saveSysRole`,
    method: 'post',
    data: sysRole,
  })
}

//角色修改
export const UpdateSysRole = sysRole => {
  return request({
    url: `${base_api}/updateSysRole`,
    method: 'put',
    data: sysRole,
  })
}

//角色删除
export const DeleteSysRole = roleId => {
  return request({
    url: `${base_api}/deleteById/${roleId}`,
    method: 'delete',
  })
}

//查询所有角色
export const GetAllRoleList = userId => {
  return request({
    url: `${base_api}/findAllRoles/${userId}`,
    method: 'get',
  })
}

//查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = roleId => {
  return request({
    url: `/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/${roleId}`,
    method: 'get',
  })
}

//保存分配
export const DoAssignMenuIdToSysRole = assignMenuDto => {
  return request({
    url: '/admin/system/sysRoleMenu/doAssign',
    method: 'post',
    data: assignMenuDto,
  })
}
